//
//  CedarTipsManager.m
//  CedarFinancePH
//
//  Created by lshenrong on 2018/4/27.
//  Copyright © 2018年 cedarhd. All rights reserved.
//

#import "CedarTipsManager.h"

#define TipsDuration 1.5

@implementation CedarTipsManager

//不遮罩
+ (void)showTipsWitText:(NSString *)text inView:(UIView *)inView{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:inView animated:YES];
    hud.mode = MBProgressHUDModeText;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.backgroundColor = [[UIColor blackColor]colorWithAlphaComponent:0.6f];
    //  hud.backgroundColor = [UIColor clearColor];
    hud.detailsLabel.textColor = [UIColor whiteColor];
    hud.detailsLabel.font = [UIFont boldSystemFontOfSize:15.0];
    hud.detailsLabel.text = text;
    hud.removeFromSuperViewOnHide = YES;
    hud.userInteractionEnabled = NO;
    [hud hideAnimated:YES afterDelay:TipsDuration];
}

+ (void)showTipsInWindowWithOnlyText:(NSString *)text{
    if([text length]>0){
        UIWindow *window = nil;
        id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
        if ([delegate respondsToSelector:@selector(window)]) {
            window = [delegate performSelector:@selector(window)];
        } else {
            window = [[UIApplication sharedApplication] keyWindow];
        }
        [self showTipsWitText:text inView:window];
    }
}


+ (void)showWaitTipsInView:(UIView *)inView{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:inView animated:YES];
    hud.mode = MBProgressHUDModeIndeterminate;
    CGPoint point = hud.offset;
    point.y -= 20;
    hud.offset = point;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.color = [[UIColor blackColor]colorWithAlphaComponent:0.6f];
    hud.contentColor = [UIColor whiteColor];
}

+ (void)hideWaitTipsView:(UIView *)inView{
    [MBProgressHUD hideHUDForView:inView animated:YES];
}

+ (void)showWaitTipsInView:(UIView *)inView text:(NSString *)text{
    MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:inView animated:YES];
    hud.mode = MBProgressHUDModeIndeterminate;
    CGPoint point = hud.offset;
    point.y -= 20;
    hud.offset = point;
    hud.bezelView.style = MBProgressHUDBackgroundStyleSolidColor;
    hud.bezelView.color = [[UIColor blackColor]colorWithAlphaComponent:0.6f];
    hud.contentColor = [UIColor whiteColor];
    hud.detailsLabel.textColor = [UIColor whiteColor];
    hud.detailsLabel.font = [UIFont boldSystemFontOfSize:15.0];
    hud.detailsLabel.text = text;
}

+ (void)hideWaitTipsViewWithText:(UIView *)inView{
    [MBProgressHUD hideHUDForView:inView animated:YES];
}


@end
